import { NativeModules } from 'react-native'

const {RNRecorder} = NativeModules

export default class RecorderManager {

  static isSpeakerphoneOn (): Promise {
    return RNRecorder.isSpeakerphoneOn()
  }

  static setSpeakerphoneOn (isSpeakerphoneOn): Promise {
    return RNRecorder.setSpeakerphoneOn(isSpeakerphoneOn)
  }

  static startPlaying (url=null, position=0): void {
      RNRecorder.startPlaying(url, position)
  }

  static stopPlaying () {
    RNRecorder.stopPlaying()
  }

  static pausePlaying () {
    RNRecorder.pausePlaying()
  }

  static resumePlaying () {
    RNRecorder.resumePlaying()
  }

  static startRecording (recordingLength) {
    RNRecorder.startRecording(recordingLength)
  }

  static pauseRecording () {
    RNRecorder.pauseRecording()
  }

  static stopRecording () {
    RNRecorder.stopRecording()
  }

  static destroy () {
    this.stopRecording();
    this.stopPlaying();
  }

}
